import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

import generics.BaseInfo;
import generics.Person;
import generics.Student;
import generics.TestListener;

public class Main {
    public static void main(String[] args) {
        System.out.println("============Start============");
        Student<BaseInfo> person = new Student<>();
        person.setData(new BaseInfo("张三", 20, new TestListener<String, Integer>() {
            @Override
            public void log(String log) {
                System.out.println("接口反的："+log);
                System.out.println("接口 Start -----");
                Type type = getClass().getGenericSuperclass();
                System.out.println("类型："+type);
                Class<?> superclass = getClass().getSuperclass();
                System.out.println("类型："+superclass);

                if (type instanceof ParameterizedType){
                    System.out.println("有泛型");
                    Type[] types = ((ParameterizedType) type).getActualTypeArguments();
                    System.out.println(types[0]);
                }

//                Type[] genericInterfaces = getClass().getGenericInterfaces();
//                System.out.println("类型："+genericInterfaces.length);
//                Type anInterface = genericInterfaces[0];
//                System.out.println("genericInterfaces："+ anInterface);
//
//                if (anInterface instanceof ParameterizedType){
//                    System.out.println("有泛型");
//                    Type[] types = ((ParameterizedType) anInterface).getActualTypeArguments();
//                    System.out.println(types[0]);
//                }

                System.out.println("接口 End -----");
            }

            @Override
            public void log() {

            }
        }));
        System.out.println(person.getData().toString());
        System.out.println("=============End=============");
    }
}
